# -*- coding:utf-8 -*- 
import sys

a = "中文编程"  ##引用计数开始是3，然后a变量引用了字符串对象3 + 1 =4
print "a:%s" % id(a)

b = a
print "b:%s" % id(b)##4 + 1 = 5

c = a
print "c:%s" % id(c)## 5 + 1 = 6

print sys.getrefcount('中文编程')##输出结果是6
print 'ssss'
a = "python编程"
print "a:%s" % id(a)###6-1 = 5##a引用另外一个字符串对象

b = u'%s' % a.decode('utf-8')
print "b:%s" % id(b)###5-1 = 4

print sys.getrefcount('中文编程')##输出结果是4

d = "中文编程"
print "d:%s" % id(d)###新建一个变量，引用字符串 4 + 1 = 5

e = a
print "e:%s" % id(e)

c = b
print "c:%s" % id(c)### c引用另外一个字符串对象，5 - 1 = 4

print sys.getrefcount('中文编程')


b2 = a.replace("中","中")
print "b2:%s" % id(b2)

print 'result-----------------'
print sys.getrefcount('中文编程')
print sys.getrefcount('python编程')